feat!: Change Pandas timestamp resolution to ms for timestamp attributes#2485
feat!: Change Pandas timestamp resolution to ms for timestamp attributes#2485MortGron wants to merge 5 commits intopysdk-release-v8from
Conversation
Summary of ChangesHello @MortGron, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request standardizes the Pandas timestamp resolution within the SDK's Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request changes the timestamp resolution from nanoseconds to milliseconds in to_pandas methods to align with CDF's native millisecond precision. The changes are implemented correctly in cognite/client/utils/_pandas_helpers.py and cognite/client/data_classes/_base.py. All related tests have been updated to reflect this new behavior, ensuring the change is well-tested. The code modifications are logical and adhere to the project's style guide. I found no high or critical severity issues.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## pysdk-release-v8 #2485 +/- ##
=================================================
Coverage 64.59% 64.60%
=================================================
Files 467 467
Lines 47789 47808 +19
=================================================
+ Hits 30871 30887 +16
- Misses 16918 16921 +3
🚀 New features to boost your workflow:
|
Description
Currently when using
to_pandason list like objects a timestamp resolution of 'ns' is enforced for both Pandas v2 and v3. For single Cognite resources that have only timestamp attributes, resolution will be 'ns' in Pandas v2 and 'ms' in v3. For single Cognite resources that have at least on timestamp attribute and at least one non-timestamp attribute, time resolution will be 'ms' in both v2 and v3.In Pandas v3 the timestamp resolution is to a much larger extent inferred from the input data, where Pandas v2 would automatically set resolution 'ns'. CDF has a resolution of 'ms', so it would make sense for the
to_pandasmethods to also convert timestamp columns toms.An example where keeping resolution 'ns' would be inconenient in Pandas v3 is when using the
from pandas.testing import assert_frame_equalwhere the resolution of timestamp columns are compared.Checklist:
If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.